Imports MetaView.AnnotatedImage

Public Class AnnotationProperties
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.IContainer

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  Friend WithEvents btnCancel As System.Windows.Forms.Button
  Friend WithEvents btnOk As System.Windows.Forms.Button
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents Label3 As System.Windows.Forms.Label
  Friend WithEvents chkVisible As System.Windows.Forms.CheckBox
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents txtText As System.Windows.Forms.TextBox
  Friend WithEvents pnlColor As System.Windows.Forms.Panel
  Friend WithEvents btnColor As System.Windows.Forms.Button
  Friend WithEvents AnnColorDialog As System.Windows.Forms.ColorDialog
  Friend WithEvents Label4 As System.Windows.Forms.Label
  Friend WithEvents chkClosed As System.Windows.Forms.CheckBox
  Friend WithEvents Label5 As System.Windows.Forms.Label
  Friend WithEvents nudMaximumNrPts As System.Windows.Forms.NumericUpDown
  Friend WithEvents nudPointSize As System.Windows.Forms.NumericUpDown
  Friend WithEvents Label6 As System.Windows.Forms.Label
  Friend WithEvents Panel1 As System.Windows.Forms.Panel
  Friend WithEvents rdComplement As System.Windows.Forms.RadioButton
  Friend WithEvents rdXor As System.Windows.Forms.RadioButton
  Friend WithEvents rdIntersect As System.Windows.Forms.RadioButton
  Friend WithEvents rdUnion As System.Windows.Forms.RadioButton
  Friend WithEvents rdOpen As System.Windows.Forms.RadioButton
  Friend WithEvents rdText As System.Windows.Forms.RadioButton
  Friend WithEvents rdLoosePoints As System.Windows.Forms.RadioButton
  Friend WithEvents rdCustom As System.Windows.Forms.RadioButton
  Friend WithEvents rdClosedContour As System.Windows.Forms.RadioButton
  Friend WithEvents pnlQuickSets As System.Windows.Forms.Panel
  Friend WithEvents rdLine As System.Windows.Forms.RadioButton
  Friend WithEvents txtKey As System.Windows.Forms.TextBox
  Friend WithEvents Label7 As System.Windows.Forms.Label
  Friend WithEvents Label8 As System.Windows.Forms.Label
  Friend WithEvents nudLineWidth As System.Windows.Forms.NumericUpDown
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnCancel = New System.Windows.Forms.Button
        Me.btnOk = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.chkVisible = New System.Windows.Forms.CheckBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.txtText = New System.Windows.Forms.TextBox
        Me.AnnColorDialog = New System.Windows.Forms.ColorDialog
        Me.pnlColor = New System.Windows.Forms.Panel
        Me.btnColor = New System.Windows.Forms.Button
        Me.Label4 = New System.Windows.Forms.Label
        Me.nudPointSize = New System.Windows.Forms.NumericUpDown
        Me.chkClosed = New System.Windows.Forms.CheckBox
        Me.nudMaximumNrPts = New System.Windows.Forms.NumericUpDown
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Panel1 = New System.Windows.Forms.Panel
        Me.rdComplement = New System.Windows.Forms.RadioButton
        Me.rdXor = New System.Windows.Forms.RadioButton
        Me.rdIntersect = New System.Windows.Forms.RadioButton
        Me.rdUnion = New System.Windows.Forms.RadioButton
        Me.pnlQuickSets = New System.Windows.Forms.Panel
        Me.rdLine = New System.Windows.Forms.RadioButton
        Me.rdClosedContour = New System.Windows.Forms.RadioButton
        Me.rdOpen = New System.Windows.Forms.RadioButton
        Me.rdText = New System.Windows.Forms.RadioButton
        Me.rdLoosePoints = New System.Windows.Forms.RadioButton
        Me.rdCustom = New System.Windows.Forms.RadioButton
        Me.txtKey = New System.Windows.Forms.TextBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.nudLineWidth = New System.Windows.Forms.NumericUpDown
        Me.Label8 = New System.Windows.Forms.Label
        CType(Me.nudPointSize, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.nudMaximumNrPts, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.Panel1.SuspendLayout()
        Me.pnlQuickSets.SuspendLayout()
        CType(Me.nudLineWidth, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btnCancel
        '
        Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnCancel.Location = New System.Drawing.Point(218, 326)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(64, 32)
        Me.btnCancel.TabIndex = 7
        Me.btnCancel.Text = "Cancel"
        '
        'btnOk
        '
        Me.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOk.Location = New System.Drawing.Point(130, 326)
        Me.btnOk.Name = "btnOk"
        Me.btnOk.Size = New System.Drawing.Size(64, 32)
        Me.btnOk.TabIndex = 6
        Me.btnOk.Text = "Ok"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(6, 120)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(128, 16)
        Me.Label1.TabIndex = 14
        Me.Label1.Text = "Color"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(7, 149)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(62, 16)
        Me.Label3.TabIndex = 16
        Me.Label3.Text = "Text"
        '
        'chkVisible
        '
        Me.chkVisible.CheckAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.chkVisible.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.chkVisible.Location = New System.Drawing.Point(6, 88)
        Me.chkVisible.Name = "chkVisible"
        Me.chkVisible.Size = New System.Drawing.Size(142, 24)
        Me.chkVisible.TabIndex = 21
        Me.chkVisible.Text = "Visible"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(6, 235)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(128, 16)
        Me.Label2.TabIndex = 28
        Me.Label2.Text = "Region add"
        '
        'txtText
        '
        Me.txtText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtText.Location = New System.Drawing.Point(136, 148)
        Me.txtText.Name = "txtText"
        Me.txtText.Size = New System.Drawing.Size(260, 20)
        Me.txtText.TabIndex = 29
        '
        'AnnColorDialog
        '
        Me.AnnColorDialog.AnyColor = True
        '
        'pnlColor
        '
        Me.pnlColor.Location = New System.Drawing.Point(136, 116)
        Me.pnlColor.Name = "pnlColor"
        Me.pnlColor.Size = New System.Drawing.Size(22, 21)
        Me.pnlColor.TabIndex = 30
        '
        'btnColor
        '
        Me.btnColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnColor.Location = New System.Drawing.Point(170, 116)
        Me.btnColor.Name = "btnColor"
        Me.btnColor.Size = New System.Drawing.Size(69, 21)
        Me.btnColor.TabIndex = 31
        Me.btnColor.Text = "Select"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(9, 178)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(54, 16)
        Me.Label4.TabIndex = 32
        Me.Label4.Text = "Point size"
        '
        'nudPointSize
        '
        Me.nudPointSize.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.nudPointSize.Location = New System.Drawing.Point(137, 176)
        Me.nudPointSize.Maximum = New Decimal(New Integer() {64, 0, 0, 0})
        Me.nudPointSize.Name = "nudPointSize"
        Me.nudPointSize.Size = New System.Drawing.Size(55, 20)
        Me.nudPointSize.TabIndex = 33
        Me.nudPointSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'chkClosed
        '
        Me.chkClosed.CheckAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.chkClosed.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.chkClosed.Location = New System.Drawing.Point(7, 262)
        Me.chkClosed.Name = "chkClosed"
        Me.chkClosed.Size = New System.Drawing.Size(142, 24)
        Me.chkClosed.TabIndex = 34
        Me.chkClosed.Text = "Closed"
        '
        'nudMaximumNrPts
        '
        Me.nudMaximumNrPts.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.nudMaximumNrPts.Location = New System.Drawing.Point(139, 290)
        Me.nudMaximumNrPts.Maximum = New Decimal(New Integer() {256, 0, 0, 0})
        Me.nudMaximumNrPts.Minimum = New Decimal(New Integer() {1, 0, 0, -2147483648})
        Me.nudMaximumNrPts.Name = "nudMaximumNrPts"
        Me.nudMaximumNrPts.Size = New System.Drawing.Size(55, 20)
        Me.nudMaximumNrPts.TabIndex = 36
        Me.nudMaximumNrPts.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        Me.nudMaximumNrPts.Value = New Decimal(New Integer() {1, 0, 0, -2147483648})
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(8, 290)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(126, 29)
        Me.Label5.TabIndex = 35
        Me.Label5.Text = "Maximum number of points"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(8, 42)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(128, 16)
        Me.Label6.TabIndex = 38
        Me.Label6.Text = "Quick property sets"
        '
        'Panel1
        '
        Me.Panel1.BackColor = System.Drawing.SystemColors.ControlLightLight
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel1.Controls.Add(Me.rdComplement)
        Me.Panel1.Controls.Add(Me.rdXor)
        Me.Panel1.Controls.Add(Me.rdIntersect)
        Me.Panel1.Controls.Add(Me.rdUnion)
        Me.Panel1.Location = New System.Drawing.Point(137, 228)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(261, 33)
        Me.Panel1.TabIndex = 41
        '
        'rdComplement
        '
        Me.rdComplement.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdComplement.Location = New System.Drawing.Point(176, 3)
        Me.rdComplement.Name = "rdComplement"
        Me.rdComplement.Size = New System.Drawing.Size(88, 24)
        Me.rdComplement.TabIndex = 31
        Me.rdComplement.Text = "Complement"
        '
        'rdXor
        '
        Me.rdXor.Checked = True
        Me.rdXor.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdXor.Location = New System.Drawing.Point(136, 3)
        Me.rdXor.Name = "rdXor"
        Me.rdXor.Size = New System.Drawing.Size(48, 24)
        Me.rdXor.TabIndex = 30
        Me.rdXor.TabStop = True
        Me.rdXor.Text = "Xor"
        '
        'rdIntersect
        '
        Me.rdIntersect.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdIntersect.Location = New System.Drawing.Point(64, 3)
        Me.rdIntersect.Name = "rdIntersect"
        Me.rdIntersect.Size = New System.Drawing.Size(72, 24)
        Me.rdIntersect.TabIndex = 29
        Me.rdIntersect.Text = "Intersect"
        '
        'rdUnion
        '
        Me.rdUnion.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdUnion.Location = New System.Drawing.Point(7, 3)
        Me.rdUnion.Name = "rdUnion"
        Me.rdUnion.Size = New System.Drawing.Size(88, 24)
        Me.rdUnion.TabIndex = 28
        Me.rdUnion.Text = "Union"
        '
        'pnlQuickSets
        '
        Me.pnlQuickSets.BackColor = System.Drawing.SystemColors.ControlLightLight
        Me.pnlQuickSets.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlQuickSets.Controls.Add(Me.rdLine)
        Me.pnlQuickSets.Controls.Add(Me.rdClosedContour)
        Me.pnlQuickSets.Controls.Add(Me.rdOpen)
        Me.pnlQuickSets.Controls.Add(Me.rdText)
        Me.pnlQuickSets.Controls.Add(Me.rdLoosePoints)
        Me.pnlQuickSets.Controls.Add(Me.rdCustom)
        Me.pnlQuickSets.Location = New System.Drawing.Point(137, 34)
        Me.pnlQuickSets.Name = "pnlQuickSets"
        Me.pnlQuickSets.Size = New System.Drawing.Size(257, 53)
        Me.pnlQuickSets.TabIndex = 42
        '
        'rdLine
        '
        Me.rdLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdLine.Location = New System.Drawing.Point(112, 24)
        Me.rdLine.Name = "rdLine"
        Me.rdLine.Size = New System.Drawing.Size(48, 24)
        Me.rdLine.TabIndex = 33
        Me.rdLine.Tag = "3"
        Me.rdLine.Text = "Line"
        '
        'rdClosedContour
        '
        Me.rdClosedContour.Checked = True
        Me.rdClosedContour.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdClosedContour.Location = New System.Drawing.Point(7, 24)
        Me.rdClosedContour.Name = "rdClosedContour"
        Me.rdClosedContour.Size = New System.Drawing.Size(112, 24)
        Me.rdClosedContour.TabIndex = 32
        Me.rdClosedContour.TabStop = True
        Me.rdClosedContour.Tag = "3"
        Me.rdClosedContour.Text = "Closed contour"
        '
        'rdOpen
        '
        Me.rdOpen.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdOpen.Location = New System.Drawing.Point(160, 24)
        Me.rdOpen.Name = "rdOpen"
        Me.rdOpen.Size = New System.Drawing.Size(96, 24)
        Me.rdOpen.TabIndex = 31
        Me.rdOpen.Tag = "4"
        Me.rdOpen.Text = "Open contour"
        '
        'rdText
        '
        Me.rdText.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdText.Location = New System.Drawing.Point(160, 3)
        Me.rdText.Name = "rdText"
        Me.rdText.Size = New System.Drawing.Size(88, 24)
        Me.rdText.TabIndex = 30
        Me.rdText.Tag = "1"
        Me.rdText.Text = "Text"
        '
        'rdLoosePoints
        '
        Me.rdLoosePoints.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdLoosePoints.Location = New System.Drawing.Point(72, 3)
        Me.rdLoosePoints.Name = "rdLoosePoints"
        Me.rdLoosePoints.Size = New System.Drawing.Size(88, 24)
        Me.rdLoosePoints.TabIndex = 29
        Me.rdLoosePoints.Tag = "2"
        Me.rdLoosePoints.Text = "Loose Points"
        '
        'rdCustom
        '
        Me.rdCustom.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.rdCustom.Location = New System.Drawing.Point(7, 3)
        Me.rdCustom.Name = "rdCustom"
        Me.rdCustom.Size = New System.Drawing.Size(65, 24)
        Me.rdCustom.TabIndex = 28
        Me.rdCustom.Tag = "0"
        Me.rdCustom.Text = "Custom"
        '
        'txtKey
        '
        Me.txtKey.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtKey.Enabled = False
        Me.txtKey.Location = New System.Drawing.Point(137, 8)
        Me.txtKey.Name = "txtKey"
        Me.txtKey.Size = New System.Drawing.Size(200, 20)
        Me.txtKey.TabIndex = 44
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(7, 9)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(132, 16)
        Me.Label7.TabIndex = 43
        Me.Label7.Text = "Unique Key or Name"
        '
        'nudLineWidth
        '
        Me.nudLineWidth.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.nudLineWidth.Location = New System.Drawing.Point(137, 204)
        Me.nudLineWidth.Maximum = New Decimal(New Integer() {64, 0, 0, 0})
        Me.nudLineWidth.Name = "nudLineWidth"
        Me.nudLineWidth.Size = New System.Drawing.Size(55, 20)
        Me.nudLineWidth.TabIndex = 46
        Me.nudLineWidth.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(9, 207)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(66, 16)
        Me.Label8.TabIndex = 45
        Me.Label8.Text = "Line width"
        '
        'AnnotationProperties
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(401, 362)
        Me.Controls.Add(Me.nudLineWidth)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.txtKey)
        Me.Controls.Add(Me.txtText)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.pnlQuickSets)
        Me.Controls.Add(Me.Panel1)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.nudMaximumNrPts)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.chkClosed)
        Me.Controls.Add(Me.nudPointSize)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.btnColor)
        Me.Controls.Add(Me.pnlColor)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.chkVisible)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.btnOk)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "AnnotationProperties"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "ROI properties"
        CType(Me.nudPointSize, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.nudMaximumNrPts, System.ComponentModel.ISupportInitialize).EndInit()
        Me.Panel1.ResumeLayout(False)
        Me.pnlQuickSets.ResumeLayout(False)
        CType(Me.nudLineWidth, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Public Sub SetDialogNewProperties(ByVal oAnnCon As AnnotatedImage.AnnotationContainer)
        pnlColor.BackColor = Color.FromArgb(oAnnCon.Color.R, oAnnCon.Color.G, oAnnCon.Color.B)

        'Closed and maxmum nr of points are only releveant when doing interactive creation
        txtKey.Enabled = True
        chkClosed.Enabled = True
        nudMaximumNrPts.Enabled = True
        pnlQuickSets.Enabled = True
    End Sub

    Public Sub SetDialogProperties(ByVal oAnn As AnnotatedImage.Annotation)
        'Set all the dialog properties using the annotation values

        Select Case oAnn.RegionAddMode
            Case RegionAddMode.Complement
                rdComplement.Checked = True
            Case RegionAddMode.Intersect
                rdIntersect.Checked = True
            Case RegionAddMode.Union
                rdUnion.Checked = True
            Case RegionAddMode.XorMode
                rdXor.Checked = True
        End Select

        txtKey.Text = oAnn.Key
        txtText.Text = oAnn.Text
        chkVisible.Checked = oAnn.Visible
        pnlColor.BackColor = Color.FromArgb(oAnn.Color.R, oAnn.Color.G, oAnn.Color.B)
        nudPointSize.Value = oAnn.PointSize
        nudLineWidth.Value = oAnn.LineWidth

        'Closed and maxmum nr of points are only releveant when doing interactive creation
        chkClosed.Checked = oAnn.Closed
        nudMaximumNrPts.Value = oAnn.MaximumNumberOfPoints
        'chkClosed.Enabled = False
        nudMaximumNrPts.Enabled = False
        pnlQuickSets.Enabled = False
    End Sub

    Public Overloads Function SetAnnotationProperties(ByVal oAnnContainer As AnnotatedImage.AnnotationContainer) As Annotation
        'We create a new annotation in given container
        Dim strKey As String
        If txtKey.TextLength > 0 Then
            strKey = txtKey.Text
        Else
            Dim iID As Integer = 1
            Do While oAnnContainer.Annotations.KeyExists("Annotation " & iID)
                iID = iID + 1
            Loop
            strKey = "Annotation " & iID
        End If

        Dim oAnn As New Annotation
        oAnnContainer.Annotations.Add(oAnn, strKey)
        SetAnnotationProperties(oAnn)
        Return oAnn
    End Function

  Public Overloads Sub SetAnnotationProperties(ByVal oAnn As Annotation)
    'Set all the properties using the dialog values

    If rdComplement.Checked Then oAnn.RegionAddMode = RegionAddMode.Complement
    If rdUnion.Checked Then oAnn.RegionAddMode = RegionAddMode.Union
    If rdIntersect.Checked Then oAnn.RegionAddMode = RegionAddMode.Intersect
    If rdXor.Checked Then oAnn.RegionAddMode = RegionAddMode.XorMode

    oAnn.Color = pnlColor.BackColor
    oAnn.Text = txtText.Text
    oAnn.Visible = chkVisible.Checked
        oAnn.PointSize = CInt(nudPointSize.Value)
        oAnn.LineWidth = CInt(nudLineWidth.Value)
        oAnn.MaximumNumberOfPoints = CInt(nudMaximumNrPts.Value)
    oAnn.Closed = chkClosed.Checked
  End Sub

  Private Sub btnColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnColor.Click
        If AnnColorDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            pnlColor.BackColor = AnnColorDialog.Color
        End If
  End Sub

  Private Sub rdClosedContour_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdClosedContour.CheckedChanged
    If rdClosedContour.Checked Then
      'Closed contour or polygon
      chkVisible.Checked = True
      'chkTextVisible.Checked = True
      'chkPointsVisible.Checked = True
      'chkLinesVisible.Checked = True
            nudLineWidth.Value = CDec(0.5)
            nudPointSize.Value = 0
      chkClosed.Checked = True
      nudMaximumNrPts.Value = -1
    End If
  End Sub

  Private Sub rdLoosePoints_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdLoosePoints.CheckedChanged
    If rdLoosePoints.Checked Then
      'Markers, e.g. for counting objects
      chkVisible.Checked = True
      'chkTextVisible.Checked = True
      'chkPointsVisible.Checked = True
      'chkLinesVisible.Checked = False
      nudPointSize.Value = 7
      nudLineWidth.Value = 0
      chkClosed.Checked = False
      nudMaximumNrPts.Value = -1
    End If
  End Sub

  Private Sub rdText_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdText.CheckedChanged
    'Text at one location
    chkVisible.Checked = True
    'chkTextVisible.Checked = True
    'chkPointsVisible.Checked = True
    'chkLinesVisible.Checked = False
    nudPointSize.Value = 3
    nudLineWidth.Value = 0
    chkClosed.Checked = False
    nudMaximumNrPts.Value = 1
  End Sub

  Private Sub rdOpen_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdOpen.CheckedChanged
    'Open contour or polyline
    chkVisible.Checked = True
    'chkTextVisible.Checked = True
    'chkPointsVisible.Checked = True
    'chkLinesVisible.Checked = True
    nudPointSize.Value = 3
    nudLineWidth.Value = 1
    chkClosed.Checked = False
    nudMaximumNrPts.Value = -1
  End Sub

  Private Sub rdLine_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdLine.CheckedChanged
    'Line
    txtText.Text = "Enter name of line here"
    chkVisible.Checked = True
    'chkTextVisible.Checked = True
    'chkPointsVisible.Checked = True
    'chkLinesVisible.Checked = True
    nudPointSize.Value = 3
    nudLineWidth.Value = 1
    chkClosed.Checked = False
    nudMaximumNrPts.Value = 2
  End Sub

  Private Sub txtKey_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtKey.TextChanged
    'Key is used as text
    txtText.Text = txtKey.Text
  End Sub
End Class
